import {emit} from "@tauri-apps/api/event";
import {UserInfoType} from "../types/types.ts";
import {useUserStore} from "../stores/user.ts";
import {storeToRefs} from "pinia";

export  function sendLoginMessage() {
    let {userInfo} = storeToRefs(useUserStore());
    console.log("sendLoginMessage called:" + userInfo.value.account);
    console.log("userInfo:" + JSON.stringify(userInfo.value));
    emit("send-message", {
        sender_account: userInfo.value.account,
        to_account: userInfo.value.account,
        message_type: "TextLogin",
        content: "login success",
    }).then(() => {
        console.log("send-message-login successfully");
    });
}